package br.com.jvet.entidade;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import br.com.jvet.constante.Porte;

@Entity
@Table(name = "tbraca")
@SequenceGenerator(name = "raca_seq", sequenceName = "raca_seq", initialValue = 1, allocationSize = 1)
public class Raca implements Serializable {

	private static final long serialVersionUID = 5507514925976407944L;
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "raca_seq")
	private int codigo;
	@Column(name = "desc_raca")
	private String descricao;
	@Column
	@Enumerated(EnumType.ORDINAL)
	private Porte porte;

	public Raca() {
		super();
	}

	public int getCodigo() {
		return codigo;
	}

	public void setCodigo(int codigo) {
		this.codigo = codigo;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public Porte getPorte() {
		return porte;
	}

	public void setPorte(Porte porte) {
		this.porte = porte;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigo;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Raca other = (Raca) obj;
		if (codigo != other.codigo)
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "Raca [codigo=" + codigo + ", descricao=" + descricao
				+ ", porte=" + porte + "]";
	}
	
	public String getTable(){
		return "tb"+getClass().getSimpleName().toLowerCase();
		
	}
	
//	public static void main(String[] args) {
//
//		for (Annotation a : new Raca().getClass().getAnnotations()) {
//			Class<?> anotacao = a.annotationType();
//			System.out.println(a.toString());
//
//		}
//	}
}
